package org.jeecg.modules.common.config.influx;

import com.influxdb.LogLevel;
import com.influxdb.client.InfluxDBClient;
import com.influxdb.client.InfluxDBClientFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * influx配置类
 */
@Slf4j
@Configuration
@EnableConfigurationProperties(value = {InFluxProperties.class})
public class InfluxDbConfig {

    @Bean
    public InfluxDBClient influxDBClient(InFluxProperties inFluxProperties) {
        log.info("influxdb config，url:{} token:{}", inFluxProperties.getUrl(), inFluxProperties.getToken());
        InfluxDBClient influxDBClient = InfluxDBClientFactory.create(inFluxProperties.getUrl(), inFluxProperties.getToken().toCharArray(),
                inFluxProperties.getOrg(), inFluxProperties.getBucket());
        return influxDBClient;
    }
}
